package com.ruoyi.web.controller.lims;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lims.domain.LimsMissionIssuedChild;
import com.ruoyi.lims.service.ILimsMissionIssuedChildService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;

/**
 * 项目Controller
 * 
 * @author ruoyi
 * @date 2023-08-30
 */
@RestController
@RequestMapping("/lims/mission/issuedChild")
public class LimsMissionIssuedChildController extends BaseController
{
    @Autowired
    private ILimsMissionIssuedChildService limsMissionIssuedChildService;

    /**
     * 查询项目列表
     */
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:list')")
    @GetMapping("/list")
    public TableDataInfo list(LimsMissionIssuedChild limsMissionIssuedChild)
    {
        startPage();
        List<LimsMissionIssuedChild> list = limsMissionIssuedChildService.queryList(limsMissionIssuedChild);
        return getDataTable(list);
    }

    /**
     * 获取项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:query')")
    @GetMapping(value = "/{michildId}")
    public AjaxResult getInfo(@PathVariable("michildId") Integer michildId)
    {
        return AjaxResult.success(limsMissionIssuedChildService.getById(michildId));
    }


    /**
     * 分配执行人
     */
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:allot')")
    @Log(title = "项目", businessType = BusinessType.UPDATE)
    @PostMapping("/allot")
    public AjaxResult allot(@RequestBody LimsMissionIssuedChild limsMissionIssuedChild)
    {
            limsMissionIssuedChild.setStatus("2");

        return toAjax(limsMissionIssuedChildService.updateById(limsMissionIssuedChild));
    }


    @Log(title = "项目-上传附件", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:importReportFile')")
    @PostMapping("/importReportFile")
    public AjaxResult importReportFile(MultipartFile file, HttpServletRequest request) throws Exception
    {
        return success( limsMissionIssuedChildService.importReportFile(file, request.getParameter("ids")));
    }
    /**
     * 标记完成
     */
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:markOk')")
    @GetMapping(value = "/markOk/{ids}")
    public AjaxResult markOk(@PathVariable Collection<Long> ids)
    {
        return AjaxResult.success(limsMissionIssuedChildService.markOk(ids));
    }

    /**
     * 退回调度人
     */
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:backActioner')")
    @Log(title = "项目", businessType = BusinessType.UPDATE)
    @PostMapping("/backActioner")
    public AjaxResult backActioner(@RequestBody LimsMissionIssuedChild limsMissionIssuedChild)
    {
        return  AjaxResult.success(limsMissionIssuedChildService.backActioner(limsMissionIssuedChild));
    }
    /**
     * 退回运营经理
     */
    @PreAuthorize("@ss.hasPermi('lims:mission:issuedChild:backOwner')")
    @Log(title = "项目", businessType = BusinessType.UPDATE)
    @PostMapping("/backOwner")
    public AjaxResult backOwner(@RequestBody LimsMissionIssuedChild limsMissionIssuedChild)
    {
        return  AjaxResult.success(limsMissionIssuedChildService.backOwner(limsMissionIssuedChild));
    }
}
